#!/usr/bin/python2.7
import sys

def safeKnight(last, i, j, field, weight):
    if last == pow(len(field), 2):
        for i in xrange(N):
            print field[i]
        sys.exit()
    movesList = getMoves(i, j, field, weight)
    for x in xrange(len(movesList)):
        field[movesList[x][0]][movesList[x][1]] = last + 1
        safeKnight(last+1, movesList[x][0], movesList[x][1], field, weight)
    else:
        del movesList
        field[i][j] = 0
        last -= 1

def getWeightField(size):
    weightField = [[0 for i in xrange(size)] for i in xrange(size)]
    if size % 2 == 0:
        squareSize = size / 2
    else:
        squareSize = size / 2 + 1
    for i in xrange(squareSize):
        for j in xrange(squareSize):
            weightField[i][j] = min(i+1, j+1)
    for i in xrange(size):
        for j in xrange(size):
            weightField[i][size-j-1] = weightField[i][j]
            weightField[size-i-1][j] = weightField[i][j]
            weightField[size-i-1][size-j-1] = weightField[i][j]
    weightField[0][0] = weightField[size-1][size-1] = weightField[size-1][0] = weightField[0][size-1] = 0
    return weightField

def getMoves(i, j, field, weight):
    movesList = []

    if i+2 < len(field):
        if j-1 >= 0 and field[i+2][j-1] == 0:         # DownLeft
            movesList.append((i+2, j-1, weight[i+2][j-1]))
        if j+1 < len(field) and field[i+2][j+1] == 0: # DownRight
            movesList.append((i+2, j+1, weight[i+2][j+1]))
        
    if j+2 < len(field):
        if i+1 < len(field) and field[i+1][j+2] == 0: # RightDown
            movesList.append((i+1, j+2, weight[i+1][j+2]))
        if i-1 >= 0 and field[i-1][j+2] == 0:         # RightUp
            movesList.append((i-1, j+2, weight[i-1][j+2]))

    if i-2 >= 0:
        if j+1 < len(field) and field[i-2][j+1] == 0: # UpRight
            movesList.append((i-2, j+1, weight[i-2][j+1]))
        if j-1 >= 0 and field[i-2][j-1] == 0:         # UpLeft
            movesList.append((i-2, j-1, weight[i-2][j-1]))

    if j-2 >= 0:
        if i-1 >= 0 and field[i-1][j-2] == 0:         # LeftUp
            movesList.append((i-1, j-2, weight[i-1][j-2]))
        if i+1 < len(field) and field[i+1][j-2] == 0: # LeftDown
            movesList.append((i+1, j-2, weight[i+1][j-2]))
    sorted(movesList, key=lambda weight: weight[2])
    return movesList

N = int(raw_input('Enter field size: '))
field = [[0 for i in xrange(N)] for i in xrange(N)]
weight = getWeightField(N)

for i in xrange(N):
    for j in xrange(N):
        field[i][j] = 1
        safeKnight(field[i][j], i, j, field, weight)